package com.asia5b.a5mall.member.adapter

import android.view.View
import android.widget.EditText
import android.widget.TextView
import com.asia5b.a5mall.member.R
import com.asia5b.a5mall.member.databinding.ItemCommentagainAdapterBinding
import com.asia5b.a5mall.member.widget.UploadView
import com.asia5b.a5mall.middleware.model.member.CommentsModel
import com.asia5b.a5mall.middleware.utils.WTimeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

class CommentAgainAdapter(list: ArrayList<CommentsModel>) :
        BaseQuickAdapter<CommentsModel, BaseDataBindingHolder<ItemCommentagainAdapterBinding>>(R.layout.item_commentagain_adapter, list) {
    override fun convert(helper: BaseDataBindingHolder<ItemCommentagainAdapterBinding>, item: CommentsModel) {
        val position = helper.layoutPosition
        val binding = helper.dataBinding!!
        binding.model = item

        val upload_postcomment = helper.getView<UploadView>(R.id.upload_commentagian)
        upload_postcomment.uploadPosition = position
        upload_postcomment.selectionMedia = item.selectionMedia

        //评价时间
        val tv_commentagian_firsttime = helper.getView<TextView>(R.id.tv_commentagian_firsttime)

        val time = WTimeUtils.format("${item.create_time * 1000}", WTimeUtils.text_yyyy_MM_dd_HH_mm_ss)
        tv_commentagian_firsttime.text = time

        //只有审核通过才能显示编辑评价和上传照片
        val et_commentagian_againcontent = helper.getView<EditText>(R.id.et_commentagian_againcontent)
        val upload_commentagian = helper.getView<UploadView>(R.id.upload_commentagian)
        when (item.audit_status) {
            "PASS_AUDIT" -> {//审核通过
                et_commentagian_againcontent.visibility = View.VISIBLE
                upload_commentagian.visibility = View.VISIBLE
            }
            else -> {
                et_commentagian_againcontent.visibility = View.GONE
                upload_commentagian.visibility = View.GONE
            }
        }

    }
}